package net.chrisrichardson.ec2deployer.applications

import net.chrisrichardson.ec2deployer.core.AWSProperties
import net.chrisrichardson.ec2deployer.core.EC2
import net.chrisrichardson.ec2deployer.core.EC2Server
import net.chrisrichardson.ec2deployer.core.EC2InstanceType
import net.chrisrichardson.ec2deployer.testutil.AWSPropertiesUtil;
import net.chrisrichardson.ec2deployer.applications.MySqlServer
import net.chrisrichardson.ec2deployer.applications.MySqlServer
import net.chrisrichardson.ec2deployer.applications.SchemaSpecification
import net.chrisrichardson.ec2deployer.applications.SchemaSpecification
import net.chrisrichardson.ec2deployer.cluster.ClusterSpec

class MySqlServerIntegrationTest extends GroovyTestCase {
	void testSomething() {

	    AWSProperties awsProperties = AWSPropertiesUtil.makeAWSProperties()
	    def ec2 = new EC2(awsProperties)

	    ec2.startPolling()
	    
	    EC2Server server = ec2.newServers(1, EC2InstanceType.SMALL)[0]
	    
	    server.waitUntilRunning()

        ClusterSpec spec = new ClusterSpec().schema("fooschema", [:], [])
	    
	    MySqlServer mySqlServer = new MySqlServer(server, spec)
	    mySqlServer.configureAsMaster()
	    
	    def s3Path = "${awsProperties.accessKey}.db-test/schema.sql"
	    mySqlServer.dbSave(s3Path)
	    mySqlServer.dbRestore(s3Path)
	    
	    ec2.stop server
	}
}